///////////////////////////
//
// File: bcf_img_proc.h
//
// Author: Originally written by Dr. John Weiss (QtImageLib hellworld.h), modified by Brian Fehrman
//
// Purpose:
//
///////////////////////////

#ifndef BCF_IMG_PROC_H
#define BCF_IMG_PROC_H

#pragma once

#include <cmath>
#include <qtimagelib.h>
#include <QDebug>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
#include <time.h>

static const int NUM_PIX_VALS = 256;    //Possible number of intensity values

class BCF_Img_Proc: public QObject
{
  Q_OBJECT;

private:
  void Create_CDF( const Image &image, std::vector<uint> &histogram, std::vector<float> &CDF, const float total_pixels);
  void Create_Histogram( const Image &image, std::vector<uint> &histogram );
  int Determine_Percentile( const std::vector<uint> &histogram, float percentile );

public slots:

  //Histogram Menu
    bool Menu_Histogram_Display_Histogram(Image &image);
    bool Menu_Histogram_Contrast_Stretch(Image &image,
                                          const float lower_percentile = 0.05,
                                          const float upper_percentile = 0.95);
    bool Menu_Histogram_Contrast_Stretch_Specify( Image &image );
    bool Menu_Histogram_Equalize( Image &image );
    bool Menu_Histogram_Equalize_Clip( Image &image );


  //Palette Menu
    bool Menu_Palette_Brightness(Image &image);
    bool Menu_Palette_Contrast(Image &image);
    bool Menu_Palette_Gamma(Image &image);
    bool Menu_Palette_Grayscale(Image &image);
    bool Menu_Palette_Log(Image &image);
    bool Menu_Palette_Negate(Image &image);
    bool Menu_Palette_Posterize(Image &image);
    bool Menu_Palette_Psuedo8(Image &image);
    bool Menu_Palette_Psuedo_Continuous(Image &image);
    bool Menu_Palette_Random_Color(Image &image);

   //Segment Menu
    bool Menu_Segment_Binary_Threshold(Image &image);
};

/*
 * Notes:
 *
 * - The class definition must appear in a header file. Multiple classes may
 *   be defined in a single file, but copying the definition above into the
 *   implementation file and removing the header will cause problems.
 *
 * - For every class that has menu items that you want to expose:
 *   - The class must inherit from QObject. Multiple inheritance is allowed
 *     as long as 'public QObject' appears first.
 *   - The class must have the 'Q_OBJECT' macro at the top of the class
 *     definition. Build errors will occur if you forget the macro, or if
 *     you attempt to place it somewhere else within the class definition.
 *
 * - For every menu item that you want to expose:
 *   - The method must appear under 'public slots:' or Qt ImageLib will not
 *     be able to find the method. The method's class must also have the
 *     'Q_OBJECT' macro, and inherit from QObject, as described above.
 *   - The method must take one of the two following forms:
 *     - void Prefix_*_Suffix();
 *     - bool Prefix_*_Suffix(Image &);
 *   - To avoid name conflicts, the method should include a special,
 *     user-defined prefix and/or suffix. You can specify these tags when
 *     starting the application in 'int main()'. By default, the prefix is
 *     'Menu_' and there is no suffix. Methods without these tags are ignored.
 *
 * - The name of the menu item will be taken from the method name. Also,
 *   optionally a name for the drop-down menu can be specified, by using the
 *   format DropDownName_ItemName. All other underscores, and changes in
 *   upper/lower case, are treated as spaces. There are better ways to
 *   specify menu names, but they are beyond the scope of this example.
 */

#endif // BCF_IMG_PROC_H
